package exer01;

/**
 * @author shkstart
 * @date 2022/5/12 - 22:00
 */
public class GeometricTest {
    public static void main(String[] args) {
        GeometricTest geometricTest = new GeometricTest();
        Circle c1 = new Circle(2,"黄色",3.14);
        MyRectangle c2 = new MyRectangle(3,4,"红色",3.88);
        geometricTest.equalsArea(c1,c2);

        geometricTest.displayGeometricObject(c2);
    }


    public void  equalsArea(GeometricObject g1,GeometricObject g2) {
        if(g1.findArea() == g2.findArea()) {
            System.out.println("两个对象的面积相等");
        }else {
            System.out.println("两个对象的面积不相等");
        }
        if (g1 instanceof Circle) {
            System.out.println("g1 is a Circle,findArea is:" + g1.findArea() );
        }
        if (g1 instanceof MyRectangle) {
            System.out.println("g1 is a MyRectangle,findArea is:" + g1.findArea() );
        }
        if (g2 instanceof Circle) {
            System.out.println("g2 is a Circle,findArea is:" + g2.findArea() );
        }
        if (g2 instanceof MyRectangle) {
            System.out.println("g1 is a MyRectangle,findArea is:" + g2.findArea() );
        }
    }
    public void displayGeometricObject(GeometricObject o) {
        System.out.println("面积为：" + o.findArea());
    }
}
